Skip to content

Delete content on flag approval #6609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2025
Merged

Conversation

akatsoulas
Copy link
Collaborator

No description provided.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the deletion behavior for flagged posts to streamline the content cleanup process upon flag approval. The changes update the user deletion handler to reassign authors instead of explicitly deleting flagged posts, add deletion logic to the FlaggedObject model’s save method to delete system user content upon flag approval, and introduce new tests to verify these behaviors.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
kitsune/forums/handlers.py Removed explicit flagged post deletion logic and updated author instead.
kitsune/flagit/models.py Added deletion logic in the save method for system users when a flag is approved.
kitsune/flagit/tests/test_models.py Added tests covering deletion scenarios based on flag approval.
Comments suppressed due to low confidence (1)

kitsune/flagit/models.py:82

  • Deleting both the content object and the flagged object directly in the save method may bypass post-delete signals or cleanup hooks. Consider reviewing this deletion order to ensure that all necessary cascading or signal-driven behavior is preserved.
self.delete()

@@ -20,19 +18,4 @@ class PostListener(UserDeletionListener):
"""Handles post cleanup when a user is deleted."""

def on_user_deletion(self, user: User) -> None:
Copy link
Preview

Copilot AI Apr 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous logic explicitly deleted flagged posts while now all posts are simply updated. Please verify that flagged posts, which might require deletion upon flag approval, are handled as intended in the new design.

Suggested change
def on_user_deletion(self, user: User) -> None:
def on_user_deletion(self, user: User) -> None:
# Delete flagged posts authored by the user
Post.objects.filter(author=user, flagged=True).delete()
# Update remaining posts to change the author to the bot user

Copilot uses AI. Check for mistakes.

@akatsoulas akatsoulas merged commit 904c34f into mozilla:main Apr 3, 2025
2 checks passed
@akatsoulas akatsoulas deleted the flags-forums branch April 3, 2025 08:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants